package cn.tedu.micro.demo.all.controller;

import cn.tedu.micro.demo.all.service.OrderService;
import cn.tedu.micro.demo.common.protocol.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("submit")
    public JsonResult<Boolean> submitOrder(Integer userId, String productCode, Integer count) {
        boolean res = orderService.submitOrder(userId, productCode, count);
        if (res) {
            return JsonResult.ok("下单成功", res);
        } else {
            return JsonResult.ok("下单失败", res);
        }
    }
}
